import { rule, not } from "nexus-plugin-shield";
import { getUserId } from "../utils";

const isAuthenticated = rule({ cache: "contextual" })(
  async (parent, args, ctx, info) => {
    const userId = getUserId(ctx.token);
    return Boolean(userId);
  }
);

const rules = {
  Query: {
    // user: isAuthenticated,
    // users: isAuthenticated,
    // userProjects: isAuthenticated,
  },
  Mutation: {
    // createUser: isAuthenticated,
    // deleteUser: isAuthenticated,
    // signup: not(isAuthenticated),
    // createProject: isAuthenticated,
  },
};

export { rules };
